import { COLUMNS } from './index.const';
import ElEditable from '@components/el-editable';
import { IndexService } from './index.service';
const indexService = new IndexService();
export default {
  components: {
    ElEditable
  },
  inject: ['apiMMallWeb'],
  data() {
    return {
      pickerOptions1: {
        disabledDate: time => {
          return time.getTime() < this.tableQuery.commitDateStart;
        }
      },
      tableQuery: {
        orderCode: '',
        orderStatus: '',
        commitDateEnd: '',
        commitDateStart: '',
        productLineCode: '',
        busModel: 1
      },
      tableData: {},
      columns: COLUMNS,
      fullscreen: false,
      sureDialogVisible: false,
      payload: [
        {
          orderCode: '11111',
          surgeryOrderCode: 'SS202002102213371234',
          surgeryDate: '',
          surgeryType: '心内',
          surgeryHospital: '北京宣武医院',
          orderModel: 'CMAS',
          productLineName: 'MT-脊柱',
          fencang: '北京贝朗仓',
          orderStatus: 3,
          orderStatusName: '待确认',
          commitTime: '2020-03-16 21:21:14'
        }
      ],
      orderIds: []
    };
  },
  async created() {
    const data = await this.apiMMallWeb.OrderDetailListOrderV1ApiPOST({ query: { busModel: 2 } });
    // this.payload = data.content;
    indexService.getStatusName(this.payload);
  },
  mounted() {},
  methods: {
    // 重置
    queryFormReset() {
      this.$refs['queryForm'].resetFields();
    },
    // 查询
    async queryFormQuery() {
      const query = {
        busModel: 2,
        commitDateEnd: this.tableQuery.commitDateEnd,
        commitDateStart: this.tableQuery.commitDateStart,
        orderCode: this.tableQuery.orderCode,
        orderStatus: this.tableQuery.orderStatus,
        page: 0,
        pageSize: 20,
        productLineCode: this.tableQuery.productLineCode
      };
      const data = await this.apiMMallWeb.OrderDetailListOrderV1ApiPOST({
        query: query
      });
      this.payload = data.content;
      indexService.getStatusName(data.content);
    },
    // 确认弹窗
    sureDialog(scope) {
      this.sureDialogVisible = true;
      this.orderIds.push(scope.orderId);
    },
    // 确认
    async sure() {
      const data = await this.apiMMallWeb.DeleteOrderOrderV1ApiPOST({ orderIds: this.orderIds });
      this.sureDialogVisible = false;
      const res = await this.apiMMallWeb.OrderDetailListOrderV1ApiPOST({ query: {} });
      this.payload = res.content;
      indexService.getStatusName(this.payload);
    },
    // 取消确认
    concelSure() {
      this.sureDialogVisible = false;
    },
    //查看
    checkDetail(scope) {
      this.$router.push({
        path: '/other-order/short/detail',
        query: {
          id: scope.orderId
        }
      });
    }
  }
};
